//
//  cinemaTableViewCell.m
//  ui豆瓣
//
//  Created by lirui on 15/12/23.
//  Copyright © 2015年 www.lanou3g.com蓝鸥科技. All rights reserved.
//

#import "cinemaTableViewCell.h"

@implementation cinemaTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.imgview = [[UIImageView alloc] init];
        self.imgview.image =  [UIImage imageNamed:@"bg_eventlistcell"];
        [self.contentView addSubview:self.imgview];
        
        self.namelabel = [[UILabel alloc] init];
        //self.namelabel.backgroundColor = [ UIColor whiteColor];
        [self.contentView addSubview:_namelabel];
        self.namelabel.font = [UIFont systemFontOfSize:20];
        
        self.adresslabel = [[ UILabel alloc] init];
        //self.adresslabel.backgroundColor = [ UIColor yellowColor];
        [self.contentView addSubview:_adresslabel];
        _adresslabel.numberOfLines = 2;
        self.adresslabel.font = [ UIFont systemFontOfSize:15];
        self.phonelabel = [[UILabel alloc] init];
        [self.contentView addSubview:_phonelabel];
        //self.phonelabel.backgroundColor = [UIColor redColor];
        self.phonelabel.font = [ UIFont systemFontOfSize:15];
    }return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat h = [[ self class] heightWithText:_adresslabel.text];
    _adresslabel.frame =CGRectMake(20, 50, self.contentView.bounds.size.width - 35, h);
    _namelabel.frame = CGRectMake(20, 10, self.contentView.bounds.size.width - 35, 30);
    _imgview.frame = CGRectMake(10,10,self.contentView.bounds.size.width - 20 , h+60+10);
    _phonelabel.frame = CGRectMake(20, 50 + h, self.contentView.bounds.size.width - 35, 30);
    
}
+(CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGSize size = CGSizeMake(375 -30, 1000);
    CGRect rect =  [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    return rect.size.height;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
